package com.sky.converter;

import com.sky.constant.PasswordConstant;
import com.sky.constant.StatusConstant;
import com.sky.context.BaseContext;
import com.sky.dto.EmployeeDTO;
import com.sky.entity.Employee;
import org.springframework.beans.BeanUtils;
import org.springframework.util.DigestUtils;

import java.time.LocalDateTime;

public class EmpConverter {
    /**
     * 员工dto类转员工类
     * @param employeeDTO
     * @return
     */
    public static Employee EmployeeDtoToEmployee(EmployeeDTO employeeDTO) {
        Employee Result = new Employee();
        //BeanUtils.copyProperties(employeeDTO, Result);
        Result.setId(employeeDTO.getId());
        Result.setUsername(employeeDTO.getUsername());
        Result.setName(employeeDTO.getName());
        Result.setPhone(employeeDTO.getPhone());
        Result.setSex(employeeDTO.getSex());
        Result.setIdNumber(employeeDTO.getIdNumber());
        Result.setStatus(StatusConstant.ENABLE);
        Result.setPassword(DigestUtils.md5DigestAsHex(PasswordConstant.DEFAULT_PASSWORD.getBytes() ));
        return Result;
    }
}
